package com.litong.litongjiaoyu.service.impl;

import com.litong.litongjiaoyu.service.UserSessionService;
import com.litong.litongjiaoyu.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName UserSessionServiceImpl
 * @Description
 * @Author jingz
 * @Date 2020/2/1 15:33
 * @Version
 **/
@Service
public class UserSessionServiceImpl implements UserSessionService {

    @Autowired
    private RedisUtil redisUtil;

    @Override
    public boolean haveSession(String session) {
        return redisUtil.have("user-redis-session:" + session);
    }

    @Override
    public long getSessionTime(String session) {
        return redisUtil.getStringTime(session);
    }

    @Override
    public String getValue(String session) {

        Object openid = redisUtil.get("user-redis-session:" + session);

        if(openid == null) {
            return null;
        }


        return openid.toString();
    }
}
